package Control;

/**
 *
 * @author Daniel Bustos
 */
public class ESForecasting implements IForecasting {

    @Override
    public Double[] forecast(Double[] inputs) throws IllegalArgumentException{

        if(!Validator.validate(inputs))
            throw new IllegalArgumentException("The inputs' number must be equal or greater than 5.");
        
        Double[] outputs = new Double[inputs.length  ];
        for (int i = 0; i < inputs.length; i++) {
            if (i == 0) {
                outputs[0] = inputs[0];
            } else {
                outputs[i] = outputs[i - 1] + 0.2 * (inputs[i - 1] - outputs[i - 1]);
            }
        }
        return outputs;
    }
}
